unit uCriticalSection;

interface

uses
  Windows;

type
  TCriticalSection = class
  protected
    FCriticalSection: TRTLCriticalSection;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Lock;
    procedure UnLock;
  end;

implementation

constructor TCriticalSection.Create;
begin
  inherited Create;
  InitializeCriticalSection(FCriticalSection);
end;

destructor TCriticalSection.Destroy;
begin
  DeleteCriticalSection(FCriticalSection);
  inherited Destroy;
end;

procedure TCriticalSection.Lock;
begin
  EnterCriticalSection(FCriticalSection);
end;

procedure TCriticalSection.UnLock;
begin
  LeaveCriticalSection(FCriticalSection);
end;
 

end.





